home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / LINKLIST.ZIP / VOIDLIST.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-02  |  2.1 KB  |  58 lines

  1. ///////////////////////////////////////////////////////
  2. //                                                   //
  3. //   Linked List Class Functions - Version 1.24      //
  4. //                                                   //
  5. //          By Kevin Campbell 1/12/96                //
  6. //                                                   //
  7. //                                                   //
  8. ///////////////////////////////////////////////////////
  9.  
  10. #ifndef VOID_LIST_H
  11. #define VOID_LIST_H
  12.  
  13. #include "alloc.h"
  14.  
  15. extern void terminate(char *message);
  16.  
  17. struct voidinfo{
  18.   void *data;
  19.   struct voidinfo *link;
  20.   struct voidinfo *oldlink;
  21. };
  22.  
  23. class void_list{
  24.   struct voidinfo *curr; // only single entry required for linked list
  25.   void *data;
  26.   int entries;
  27.   int curr_entry;
  28. public:
  29.   void_list(void);              // Constructor
  30.   ~void_list(void);             // DeConstructor
  31.   char add(void *tempdata=NULL);     // Adds new entry with 'size' data allocated
  32.   char kill(void);                // Removes entry from list and frees up memory
  33.   void link(voidinfo *entry);       // Links linked_list onto another
  34.   voidinfo *cutfront();             // Cut's off front of list and returns pointer
  35.   voidinfo *cutend();               // Cut's off end of list and returns pointer
  36.   char nuke(void);            // Removes all entries
  37.   void *get(void);            // Gets data from entry
  38.   char put(void *info);        // Puts data to entry
  39.  
  40.   char operator=(void *info);    // Puts data to entry
  41.   char operator--(int x);         // Uses last entry in list
  42.   char operator++(int x);         // Uses next entry in list
  43.  
  44.   char last(void);             // Uses last entry in list
  45.   char next(void);             // Uses next entry in list
  46.   char rw(void);                  // Goes to start of list
  47.   char ff(void);             // Goes to end of list
  48.   int num(void);             // Returns number of entries in list
  49.   void count(void);            // Restores info in list
  50.   void *addr(void);                // Returns pointer to data
  51.   char use(int entry);                  // Goes to specified entry in list
  52.   char find(void *fdata);        // Makes the list with data fdata current
  53. };
  54.  
  55. // *Note - all char entries return 1 on successful
  56. //         completion and 0 on failure.
  57.  
  58. #endif